#include "apue.h"
#include <unistd.h>
#include <fcntl.h>

void file_hole_test(void);

char buf1[] = "abcdefghij";
char buf2[] = "ABCDEFGHIJ";

int main(int argc, char const *argv[])
{
    file_hole_test();
    return 0;
}

void file_hole_test(void)
{
    int fd;

    if ((fd = creat("file.hole", FILE_MODE)) < 0)
    {
        err_sys("creat error");
    }
    
    if (write(fd, buf1, 10) != 10)
    {
        err_sys("buf1 write error");
    }
    /* offset now = 10 */
    
    if (lseek(fd, 0x4000, SEEK_SET) == -1)
    {
        err_sys("lseek error");
    }
    /* offset now = 0x4000 */
    
    if (write(fd, buf2, 10) != 10)
    {
        err_sys("buf2 write error");
    }
    /* offset now = 0x400A */
}